package com.youbug.mall.seckill.feign.impl;

import com.youbug.common.to.SeckillSkuRedisTo;
import com.youbug.common.to.SeckillSkuTo;
import com.youbug.common.vo.R;
import com.youbug.mall.product_pms.feign.IPmsSeckillFeignService;
import com.youbug.mall.seckill.service.ISeckillService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PmsSeckillFeignServiceImpl implements IPmsSeckillFeignService {
    @Autowired
    private ISeckillService seckillService;

    @Override
    public R<SeckillSkuTo> getSkuSeckillInfo(Long skuId) {

        SeckillSkuRedisTo seckillSkuRedisTo = seckillService.getSkuSeckillInfo(skuId);
        if(seckillSkuRedisTo==null){
            return R.fail();
        }
        SeckillSkuTo seckillSkuTo = new SeckillSkuTo();

        BeanUtils.copyProperties(seckillSkuRedisTo, seckillSkuTo);

        return R.ok(seckillSkuTo);
    }
}
